<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>

		<link rel="stylesheet" type="text/css" href="../js/bootstarp-3.3.7/css/bootstrap.min.css" />
		<script src="../vendor/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://cdn.bootcss.com/jquery.serializeJSON/2.9.0/jquery.serializejson.min.js"></script>
			
		<!--<script src="..endor/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>-->
		<script src="../js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<script src="../js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>

		<script>
		$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
			$.ajaxSetup({
				crossDomain: true,
				xhrFields: {
					withCredentials: true
				}
			});
		});
	</script> 

		<script type="text/javascript">
			$(function() {
				$("#table").bootstrapTable({
					type: "post",
					url: "http://127.0.0.1:8099/getAllReg",
					pagesize: "3",
					queryParams:queryparam,
					columns: [{
						field: "reg_id",
						title: "挂号费编号",
						align: "center",
					}, {
						field: "registeredfee_name",
						title: "挂号费类别",
						align: "center",
					}, {
						field: "registeredfee_aggregate_amount",
						title: "挂号费金额",
						align: "center",
					}, {
						title: '修改',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" onclick="xgnzReg(' + row.reg_id + ')" class="btn btn-info glyphicon glyphicon-edit" data-toggle="modal" data-target="#myModal1"></button>'
							//      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">添加</button>

						}
					}, {

						title: '删除',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" onclick="delReg(' + row.reg_id + ')" class="btn btn-danger glyphicon glyphicon-trash"></button>'
						}
					}
					
					]

				})
				
			//子费用表	
				$("#ttt").bootstrapTable({
					type: "post",
					url: "http://127.0.0.1:8099/Dzsub",
					pagesize: "3",
					queryParams:queryparams,
					columns: [{
						field: "reg_sub_id",
						title: "子费用编号",
						align: "center",
					}, {
						field: "reg_id",
						title: "挂号费ID",
						align: "center",
					}, {
						field: "sub_registeredfee_name",
						title: "子费用名称",
						align: "center",
					}, {
						field: "sub_registeredfee_fee",
						title: "子费用",
						align: "center",
					}, {
						title: '修改',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" onclick="xgnzSub(' +row.reg_sub_id + ')" class="btn btn-info glyphicon glyphicon-edit" data-toggle="modal" data-target="#myModal222"></button>'
						}
					}, {
						title: '删除',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" onclick="delsub(' + row.reg_sub_id + ')" class="btn btn-danger glyphicon glyphicon-trash"></button>'
						}  
					

						}]
    			})
				
				
				$("#sel").click(function(){	
					$("#myModal2").modal("show");		
				})
       
       //修改
       $("#xgreg").click(function(){
       	$.ajax({
       		    type:"post",   
				url:"http://127.0.0.1:8099/udReg",  
				data:$('#xgreg1').serialize(),
				success: function(data) {
							$("#myModal1").modal('hide');					
							$("#table").bootstrapTable('refresh');
					}				
       	         }) 	
               })
       
       
   //子费用修改    
       $("#xgsub").click(function () {
       	$.ajax({
       		    type:"post",   
				url:"http://127.0.0.1:8099/UpdateSub",  
				data:$('#xgsub1').serialize(),
				success: function(data) {
							$("#myModal222").modal('hide');					
							$("#ttt").bootstrapTable('refresh');
					}	
       	})
       })
       
       
       
       
       
       
       
        //添加
				$("#tjreg").click(function() {
					var a = $("#reg").serializeJSON();
					$.ajax({
						type: "post",
						url: "http://127.0.0.1:8099/InsertReg",
						data:a,
        //刷新表格
						success: function(data) {
        //关闭模态框
							$("#myModal").modal('hide');
		//刷新表格					
							$("#table").bootstrapTable('refresh');
						}
					});
				})
				
				
	//子费用添加	
			$("#tjsub")	.click(function(){
				var z =$("#zname").val();
				var c =$("#name1").val();
				$.ajax({
					type: "post",
						url: "http://127.0.0.1:8099/InsertSub",
						data:"sub_registeredfee_name="+z+"&sub_registeredfee_fee="+c,
						success: function(data) {
							$("#myModa3").modal('hide');			
							$("#ttt").bootstrapTable('refresh');
						}
					
					
				})
				
			})
				
		
        //模糊查询
				$("#cha").click(function () {
					$("#table").bootstrapTable('refresh');
				})
		
	 //子费用模糊查询		
			$("#cha2").click(function(){
				$("#ttt").bootstrapTable("refresh");						
			})
	
			})    
			
	
			//删除
			function delReg(reg_id) {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/DelReg?reg_id=" +reg_id,
					dataType:"text",
					success: function(data) {		
							if (data==1) {
								$("#table").bootstrapTable('refresh');
							} else{
								
							}
						}
				}) 			
			}	
				
	//子费用删除		
			function delsub(reg_sub_id) {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/DelSub?reg_sub_id=" +reg_sub_id,
					dataType:"text",
					success:function (data) {
						$("#ttt").bootstrapTable('refresh');
					}
				})
			}
			
	
			
			//修改拿值
			function xgnzReg(reg_id) {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/xgnzReg",
					data:"did="+reg_id,
					dataType:"json",
					success: function(data) {		
						$("#a").val(data.registeredfee_name);
						$("#xg").val(data.reg_id);
						
						$("#c").val(data.registeredfee_aggregate_amount);
						
						}
				})
			}
			
	//子费用修改拿值		
			function xgnzSub(reg_sub_id) {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/UpSub",
					data:"reg_sub_id="+reg_sub_id,
					dataType:"json",
					success: function(data) {	
						$("#xg1").val(data.reg_sub_id);
						$("#p").val(data.sub_registeredfee_name);
						$("#j").val(data.sub_registeredfee_fee);
						
						}
				})
			}
			
			
			
			
			
			
			
			
			
			
			
			
			
		
			//主拿文本框值
       function queryparam() {				  
				return{
					'registeredfee_name':$("#mhcx").val(),
				}
			}
       
       //子费用拿文本框值 
       function queryparams() {
       	return{
       		'sub_registeredfee_name':$("#mhcx2").val(),
       	}
       }
       
		
		
		</script>

	   </head>




	<body>
<br />
		<form class="form-inline">
			<div class="form-group">
				<label for="reg_id">挂号费类别</label>
				<input type="text" name="registeredfee_name" id="mhcx" value="" class="form-control" style="width: 200px;" />
				<button type="button" class="btn btn-primary" data-toggle="modal" data-target="MModal" id="cha">查询</button>
				<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">添加</button>
                <button type="button" class="btn btn-primary" data-toggle="modal" id="sel">子费用</button>

			</div>
		</form>
		<br />
<!-- 挂号费添加Modal -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">添加挂号类型</h4>
					</div>
					<div class="modal-body">

						<form class="form-inline" name="tjreg" id="reg">
							<div class="form-group">
								<label for="registeredfee_name">费用名称</label>
								<input type="text" class="form-control" name="registeredfee_name" placeholder="请输入费用名称">
							</div>

							<div class="form-group">
								<label for="registeredfee_aggregate_amount">费用金额</label>
								<input type="email" class="form-control" name="registeredfee_aggregate_amount" placeholder="请输入费用金额">
							</div>
							
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="tjreg">新增</button>
					</div>
				</div>
			</div>
		</div>


      
  <!--挂号费修改 Modal -->
		<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						
					</div>
					<div class="modal-body">

						<form class="form-inline" name="tjreg" id="xgreg1">
							<input type="hidden" name="reg_id" id="xg" value="" />
							<div class="form-group">
								<label for="registeredfee_name">费用名称</label>
								<input type="text" class="form-control" name="registeredfee_name" id="a" placeholder="请输入费用名称">
							</div>

							
							<div class="form-group">
								<label for="numberOfSub">费用金额</label>
								<input type="email" class="form-control" name="registeredfee_aggregate_amount" id="c" placeholder="请输入子费用项">
							</div>

						</form>
 
					</div>    
                 <div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="xgreg">修改</button>
					</div>
                 	</div>
			</div>
		</div>
            
            
    
            
 <!--	子费用 Modal -->
		<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

					</div>
						<div class="modal-body">
							
							<form class="form-inline" >
							<div class="form-group">
								<label for="reg_sub_id">子费用名称</label>
								<input type="text" name="" id="mhcx2" value="" class="form-control" style="width: 200px;" />
								<button type="button" class="btn btn-primary" data-toggle="modal" data-target="MModal" id="cha2">查询</button>
								<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModa3">添加</button>
							</div>	
						</form>
							
					
			<!--子费用表-->
		<table id="ttt"></table>
						
						
 
					</div>    
                 <div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
                 	</div>
			</div>
		</div>






							
				<!-- 子费用添加Modal -->
		<div class="modal fade" id="myModa3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">添加子费用名称</h4>
					</div>
					<div class="modal-body">

						<form class="form-inline" name="tjsub" id="sub">
							<div class="form-group">
								<label for="sub_registeredfee_name">子费用名称</label>
								<input type="text" class="form-control" name="sub_registeredfee_name" id="zname" placeholder="请输入子费用名称">
							</div>
							
							<div class="form-group">
								<label for="sub_registeredfee_fee">子费用</label>
								<input type="email" class="form-control" name="sub_registeredfee_fee" id="name1" placeholder="请输入子费用">
							</div>

						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="tjsub">新增</button>
					</div>
		
				</div>
			</div>
		</div>








             <!--子费用修改 Modal -->
		<div class="modal fade" id="myModal222" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						
					</div>
					<div class="modal-body">

						<form class="form-inline" name="tjreg" id="xgsub1">
							<input type="hidden" name="reg_sub_id" id="xg1" value="" />
							<div class="form-group">
								<label for="sub_registeredfee_name">子费用名称</label>
								<input type="text" class="form-control" name="sub_registeredfee_name" id="p" placeholder="请输入子费用名称">
							</div>

							
							<div class="form-group">
								<label for="sub_registeredfee_fee">子费用金额</label>
								<input type="email" class="form-control" name="sub_registeredfee_fee" id="j" placeholder="请输入子费用金额">
							</div>

						</form>
 
					</div>    
                 <div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary" id="xgsub">修改</button>
					</div>
                 	</div>
			</div>
		</div>




     
		   <!--挂号费表 -->
		<table id="table"></table>
	</body>

</html>